#include"process.h"

#define SIZE 100
#define SLEEPTIME 1000*50
#define STYLE '#'

char str[SIZE+1]={0};
char wait[]={"|/-\\"};
int cnt = 0;

void process_v1()
{
  int rate = 0, wsize = strlen(wait);
  while(rate <= SIZE)
  {
    printf("[%-100s][%d%%][%c]\r",str,rate,wait[rate%wsize]);
    fflush(stdout);
    usleep(SLEEPTIME);
    str[rate++] = STYLE;
  }
  printf("\n");
}


void process_v2(int rate)
{
  cnt++;
  int size = strlen(str);
  while(size < rate)
    str[size++] = STYLE;
  if(rate >= 0 && rate <= SIZE)
  {
    int wsize = strlen(wait);
    printf("[%-100s][%d%%][%c]\r",str,rate,wait[cnt%wsize]);
    fflush(stdout);
  }
}
